package com.stox.navigator.ui.swing.widget;

import java.awt.Component;

import javax.swing.JPopupMenu;

import com.stox.charting.ui.swing.model.price.PriceChartView;
import com.stox.charting.ui.swing.widget.ChartMenuItem;
import com.stox.charting.ui.swing.widget.OverlapMenuItem;
import com.stox.charting.ui.swing.widget.ReplaceMenuItem;
import com.stox.lists.ui.swing.widget.AddToShortListMenuItem;
import com.stox.lists.ui.swing.widget.AddToWatchListMenuItem;
import com.stox.scanner.ui.swing.widget.ScanSelectedMenuItem;

public class NavigatorPopupMenu extends JPopupMenu {
	private static final long serialVersionUID = -2329908335164786011L;

	private ReplaceMenuItem replaceMenuItem = new ReplaceMenuItem();
	private ChartMenuItem chartMenuItem = new ChartMenuItem();
	private OverlapMenuItem overlapMenuItem = new OverlapMenuItem();
	
	private AddToShortListMenuItem addToShortListMenuItem = new AddToShortListMenuItem();
	private AddToWatchListMenuItem addToWatchListMenuItem = new AddToWatchListMenuItem();
	
	private ScanSelectedMenuItem scanSelectedMenuItem = new ScanSelectedMenuItem();
	
	public NavigatorPopupMenu() {
		add(replaceMenuItem);
		add(overlapMenuItem);
		add(chartMenuItem);
		addSeparator();
		add(scanSelectedMenuItem);
		addSeparator();
		add(addToShortListMenuItem);
		add(addToWatchListMenuItem);
	}


	@Override
	public void show(Component invoker, int x, int y) {
		if(PriceChartView.getCount() > 0){
			replaceMenuItem.setEnabled(true);
			overlapMenuItem.setEnabled(true);
		}else{
			replaceMenuItem.setEnabled(false);
			overlapMenuItem.setEnabled(false);
		}
		super.show(invoker, x, y);
	}
	
	
}
